//package com.usefullc.common.swagger;
//
//
//import com.google.common.base.Predicate;
//import BaseController;
//import org.springframework.context.annotation.Bean;
//import springfox.documentation.RequestHandler;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.service.ApiKey;
//import springfox.documentation.service.AuthorizationScope;
//import springfox.documentation.service.SecurityReference;
//import springfox.documentation.service.SecurityScheme;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spi.service.contexts.SecurityContext;
//import springfox.documentation.spring.web.plugins.Docket;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import static com.google.common.collect.Lists.newArrayList;
//
//public class SwaggerConfig {
//
//    @Bean
//    public Docket swaggerEmployeeApi(SwaggerProperties swaggerProperties) {
//
//        List<SecurityScheme> securitySchemes = new ArrayList<>();
//        for (String name : swaggerProperties.getSecurity().getName()) {
//            securitySchemes.add(new ApiKey(name, name, "header"));
//        }
//        List<SecurityReference> securityReferences = new ArrayList<>();
//
//        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
//        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
//        authorizationScopes[0] = authorizationScope;
//
//        for (String name : swaggerProperties.getSecurity().getName()) {
//            securityReferences.add(new SecurityReference(name, authorizationScopes));
//        }
//
//        List<SecurityContext> authorization = newArrayList(
//                SecurityContext.builder()
//                        .securityReferences(securityReferences)
//                        .forPaths(PathSelectors.any())
//                        .build());
//
//        List<SwaggerProperties.SwaggerGroup> groups = swaggerProperties.getGroups();
//        List<Docket> dockets = new ArrayList<>();
//        for (SwaggerProperties.SwaggerGroup group : groups) {
//            return new Docket(DocumentationType.SWAGGER_2).groupName(group.getName())
//                    .select()
//                    .apis(RequestHandlerSelectors.basePackage(group.getPath()))
//                    .paths(PathSelectors.any())
//                    .build()
//                    .host(swaggerProperties.getApiHost())
//                    .securitySchemes(securitySchemes)
//                    .securityContexts(authorization)
//                    .apiInfo(new ApiInfoBuilder().version(swaggerProperties.getVersion()).title(swaggerProperties.getTitle()).description(swaggerProperties.getDescription()).build());
////            dockets.add(docket);
//
//        }
//        return  null;
//
//    }
//
//
//
//    @Bean
//    public Docket swaggerEmployeeApi2(SwaggerProperties swaggerProperties) {
//
//        List<SecurityScheme> securitySchemes = new ArrayList<>();
//        for (String name : swaggerProperties.getSecurity().getName()) {
//            securitySchemes.add(new ApiKey(name, name, "header"));
//        }
//        List<SecurityReference> securityReferences = new ArrayList<>();
//
//        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
//        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
//        authorizationScopes[0] = authorizationScope;
//
//        for (String name : swaggerProperties.getSecurity().getName()) {
//            securityReferences.add(new SecurityReference(name, authorizationScopes));
//        }
//
//        List<SecurityContext> authorization = newArrayList(
//                SecurityContext.builder()
//                        .securityReferences(securityReferences)
//                        .forPaths(PathSelectors.any())
//                        .build());
//
//        List<SwaggerProperties.SwaggerGroup> groups = swaggerProperties.getGroups();
//        List<Docket> dockets = new ArrayList<>();
//        for (SwaggerProperties.SwaggerGroup group : groups) {
//            return new Docket(DocumentationType.SWAGGER_2).groupName("111111")
//                    .select()
//                    .apis(RequestHandlerSelectors.basePackage(group.getPath()))
//                    .paths(PathSelectors.any())
//                    .build()
//                    .host(swaggerProperties.getApiHost())
//                    .securitySchemes(securitySchemes)
//                    .securityContexts(authorization)
//                    .apiInfo(new ApiInfoBuilder().version(swaggerProperties.getVersion()).title("22222222").description(swaggerProperties.getDescription()).build());
////            dockets.add(docket);
//
//        }
//        return  null;
//
//    }
//
////    @Bean
////    public List<Docket> swaggerEmployeeApi(SwaggerProperties swaggerProperties) {
////
////        List<SecurityScheme> securitySchemes = new ArrayList<>();
////        for (String name : swaggerProperties.getSecurity().getName()) {
////            securitySchemes.add(new ApiKey(name, name, "header"));
////        }
////        List<SecurityReference> securityReferences = new ArrayList<>();
////
////        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
////        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
////        authorizationScopes[0] = authorizationScope;
////
////        for (String name : swaggerProperties.getSecurity().getName()) {
////            securityReferences.add(new SecurityReference(name, authorizationScopes));
////        }
////
////        List<SecurityContext> authorization = newArrayList(
////                SecurityContext.builder()
////                        .securityReferences(securityReferences)
////                        .forPaths(PathSelectors.any())
////                        .build());
////
////        List<SwaggerProperties.SwaggerGroup> groups = swaggerProperties.getGroups();
////        List<Docket> dockets = new ArrayList<>();
////        for (SwaggerProperties.SwaggerGroup group : groups) {
////            Docket docket =  new Docket(DocumentationType.SWAGGER_2).groupName(group.getName())
////                    .select()
////                    .apis(RequestHandlerSelectors.basePackage(group.getPath()))
////                    .paths(PathSelectors.any())
////                    .build()
////                    .host(swaggerProperties.getApiHost())
////                    .securitySchemes(securitySchemes)
////                    .securityContexts(authorization)
////                    .apiInfo(new ApiInfoBuilder().version(swaggerProperties.getVersion()).title(swaggerProperties.getTitle()).description(swaggerProperties.getDescription()).build());
////            dockets.add(docket);
////
////        }
////        return  dockets;
////
////    }
//
//    private Predicate<RequestHandler> getApisPredicate() {
//        Predicate<RequestHandler> apisPredicate = requestHandler -> {
//            Class<?> superClass = requestHandler.declaringClass().getSuperclass();
//            if (superClass != null && BaseController.class.equals(superClass)) {
//                return true;
//            }
//            return false;
//        };
//        return apisPredicate;
//    }
//}
